package com.fire.control.system.entity;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * TNotice entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_notice", catalog = "fire_control_system")
public class Notice extends BaseEntity {

	private static final long serialVersionUID = 1L;
	
	@Column(name = "title", nullable = false,length=50)
	private String title;
	
	@Column(name = "content")
	private String content;
	
	@Column(name = "send_time", nullable = false)
	@Temporal(TemporalType.DATE)
	private Date sendTime;
	
	/**
	 * 有效时间
	 */
	@Column(name = "valid_time", nullable = false)
	@Temporal(TemporalType.DATE)
	private Date validTime;
	
	//发送对象，选择角色
	@ManyToMany(cascade={CascadeType.REFRESH},fetch = FetchType.LAZY) 
	@JoinTable(name="t_notice_role",
		joinColumns=@JoinColumn(name="role_id"),
		inverseJoinColumns=@JoinColumn(name="notice_id"))
	private Collection<Role> Roles;
	
	
	@ManyToOne(fetch=FetchType.EAGER,optional=false)
	@JoinColumn(name = "company_id")
	private Company company;
	
	@ManyToOne(fetch=FetchType.EAGER,optional=false)
	@JoinColumn(name = "send_user_id")
    private User user;
    
	@ManyToMany(cascade={CascadeType.REFRESH},fetch = FetchType.LAZY) 
	@JoinTable(name="t_notice_device_group",
		joinColumns=@JoinColumn(name="device_group_id"),
		inverseJoinColumns=@JoinColumn(name="notice_id"))
	private Collection<DeviceGroup> deviceGroups;
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "notice")
	private Collection<NoticeDetail> noticeDetails;
    
    
	public Date getValidTime() {
		return validTime;
	}

	public void setValidTime(Date validTime) {
		this.validTime = validTime;
	}

	public Collection<DeviceGroup> getDeviceGroups() {
		return deviceGroups;
	}

	public void setDeviceGroups(Collection<DeviceGroup> deviceGroups) {
		this.deviceGroups = deviceGroups;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	
	public Collection<Role> getRoles() {
		return Roles;
	}

	public void setRoles(Collection<Role> roles) {
		Roles = roles;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	

	public Collection<NoticeDetail> getNoticeDetails() {
		return noticeDetails;
	}

	public void setNoticeDetails(Collection<NoticeDetail> noticeDetails) {
		this.noticeDetails = noticeDetails;
	}

	

}